<?php

namespace app\admin\validate;

use think\Validate;

class LoginValidate extends Validate
{
    protected $rule = [
        'name' => 'require',
//        'name'      => 'require|unique:admin_user|max:50',
        'mobile'    => 'require|mobile',
        'password'  => 'require|max:30',
        "code"      => "require",
        "sms_type"  => "require|number",
    ];

    protected $message = [
        'user_name.require' => '用户名不能为空',
        'name.require'      => '用户名不能为空',
        'name.unique'       => '用户名已存在',
        'name.max'          => '用户名不能超过50个字符',
        'mobile.require'    => '手机号不能为空',
        'mobile.mobile'     => '手机号格式不正确',
        'password.require'  => '密码不能为空',
        'password.max'      => '密码不能超过30个字符',
        'code.require'      => '验证码不能为空',
    ];

    protected $scene = [
        'login'       => ['name', 'password'],
        'modify_pass' => ['mobile', 'password', 'platform_id', 'code'],
        'sendSms'     => ['mobile', 'platform_id', 'sms_type'],
        'login_sms'   => ['mobile', 'platform_id', 'code'],
        'del'         => ['id'],
    ];
}